package com.training.java.core.homework07.collections.sets;

public class LaptopForTreeSet implements Comparable<LaptopForTreeSet> {

	// Variables
	private String manufacturer;
	private String model;
	private double memory;
	private double diskCapacity;

	// Methods
	LaptopForTreeSet(String manufacturer, String model, double memory,
			double diskCapacity) {
		this.manufacturer = manufacturer;
		this.model = model;
		this.memory = memory;
		this.diskCapacity = diskCapacity;

		/*
		 * System.out.println("A Laptop object, manufactured by " +
		 * this.manufacturer + " model = " + this.model + " memory = " +
		 * this.memory + " disk capacity = " + this.diskCapacity +
		 * " was instantiated.");
		 */
	}

	@Override
	public int compareTo(LaptopForTreeSet that) {
		
		int returnValue = this.model.compareTo(that.model);
		if (returnValue == 0) {
			returnValue = this.model.compareTo(that.model);
		}
		

		return returnValue;
	}

@Override
	public boolean equals(Object obj) {

		if (obj instanceof LaptopForTreeSet) {
			LaptopForTreeSet that = (LaptopForTreeSet) obj;


			/***
			System.out
					.println("=================================================>>>");
			System.out.println("this.manufacturer, this.model = "
					+ this.getManufacturer() + ", " + this.getModel());

			System.out.println("that.manufacturer, that.model = "
					+ that.getManufacturer() + ", " + that.getModel());

			System.out
					.println("=================================================>>>");
			***/

			// Both of the below constructs work.
			// return ( that.getManufacturer().equals(this.getManufacturer()) &&
			// that.getModel().equals(this.getModel()) );
			return (that.manufacturer.equals(this.manufacturer) && that.model
					.equals(this.model));

		} else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (this.getManufacturer().hashCode() + this.getModel().hashCode());
	}

	// Getters
	public String getManufacturer() {
		return this.manufacturer;
	}

	public String getModel() {
		return this.model;
	}

	public double getMemory() {
		return this.memory;
	}

	public double getDiskCapacity() {
		return this.diskCapacity;
	}
}
